package com.cliang.service.dao.impl;

import com.cliang.common.BlogQueryVo;
import com.cliang.entity.Blog;
import com.cliang.service.dao.BlogDao;
import com.cliang.service.mapper.BlogMapper;
import com.cliang.tools.page.PagePartition;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class BlogDaoImpl implements BlogDao {
    @Resource
    BlogMapper blogMapper;

    @Override
    public PagePartition<Blog> getBlogList(BlogQueryVo blogQueryVo, int currntPage, int pageSize) {
        int totalRecord=blogMapper.getBlogsCount(blogQueryVo);
        PagePartition page=new PagePartition(currntPage,pageSize,totalRecord);
        int startIndex=page.getStartIndex();
        page.setList( blogMapper.getBlogLists(blogQueryVo,startIndex,pageSize));
        return page;
    }
}
